package com.companion.companion.controller;

import java.util.List;

import com.companion.companion.domain.Message;
import com.companion.companion.service.IMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 聊天消息记录Controller
 * 
 * @author zly
 * @date 2025-05-06
 */@CrossOrigin
@RestController
@RequestMapping("/system/message")
public class MessageController
{
    @Autowired
    private IMessageService messageService;

    /**
     * 查询聊天消息记录列表
     */
    @GetMapping("/list")
    public List<Message> list(Message message)
    {
        return messageService.selectMessageList(message);
    }

    /**
     * 获取聊天消息记录详细信息
     */
    @GetMapping(value = "/{messageId}")
    public Message getInfo(@PathVariable("messageId") Long messageId)
    {
        return messageService.selectMessageByMessageId(messageId);
    }

    /**
     * 新增聊天消息记录
     */
    @PostMapping
    public int add(@RequestBody Message message)
    {
        return messageService.insertMessage(message);
    }

    /**
     * 修改聊天消息记录
     */
    @PutMapping
    public int edit(@RequestBody Message message)
    {
        return messageService.updateMessage(message);
    }

    /**
     * 删除聊天消息记录
     */
    @DeleteMapping("/{messageIds}")
    public int remove(@PathVariable Long[] messageIds)
    {
        return messageService.deleteMessageByMessageIds(messageIds);
    }
}
